#
# Make file to build the DBConnect API
# Copyright (c) Johnathan Ingram 2002
#
#####################################################################

SHELL = /bin/sh
VPATH = @srcdir@

subdirs = @subdirs@
top_srcdir = @top_srcdir@
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = $(exec_prefix)/bin
infodir = $(prefix)/info
libdir = $(prefix)/lib
mandir = $(prefix)/man/man1
CC = @CC@
CXX = @CXX@
CPPFLAGS = @CPPFLAGS@
CFLAGS = $(CPPFLAGS) @CFLAGS@ @OS_DEF@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
INSTALL = @INSTALL@

all:
	@for dir in ${subdirs}; do \
		(cd $$dir && $(MAKE) all) || exit 1; \
	done
	@echo "Now type 'make example' if you would like to build the examples"


clean:
	@for dir in ${subdirs}; do \
		(cd $$dir && $(MAKE) clean) || exit 1; \
	done
	rm -f ./include/dbconn/*.h
	rm -f ./include/*.h
	rm -f ./lib/*.a
	rm -f ./lib/*.so
	rm -f ./lib/drivers/*.so
	(cd ./examples && make clean && cd -) || exit 1;


example:
	(cd ./examples && make all && cd -) || exit 1;


distclean:	
	make clean
	rm -f ./config.log
	rm -f ./config.status
	rm -rf ./*.cache
	rm -f ./Makefile
	@for dir in ${subdirs}; do \
		(rm -f $$dir/Makefile) || exit 1; \
	done
	rm -f ./examples/Makefile
	find ./ -name "core" -print | xargs rm -f


sourceballs:
	make distclean
	@echo "Building source tarball"
	(cd .. && tar cvfz dbconnect-@dbconn_version@.tar.gz dbconnect-@dbconn_version@ --exclude dev --exclude CVS && cd -) || exit 1;
	@echo "Building source zip"
	(cd .. && find dbconnect-@dbconn_version@ -name "*" -print | grep -v "/dev" | grep -v "/CVS" | zip dbconnect-@dbconn_version@.zip -@ && cd -) || exit1;

